/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.fee.core.repository.entity;

import com.gitee.peigenlpy.actable.annotation.Column;
import com.gitee.peigenlpy.actable.annotation.Index;
import com.gitee.peigenlpy.actable.annotation.Table;
import com.gitee.peigenlpy.actable.annotation.Unique;
import com.gitee.peigenlpy.actable.constants.MySqlCharsetConstant;
import com.gitee.peigenlpy.actable.constants.MySqlEngineConstant;
import com.gitee.peigenlpy.actable.constants.MySqlTypeConstant;
import info.peigen.hotpot.business.fee.facade.enums.FeeMethod;
import info.peigen.hotpot.business.fee.facade.enums.FeeProductCode;
import info.peigen.hotpot.business.fee.facade.enums.FeeType;
import info.peigen.hotpot.common.core.enums.Currency;
import info.peigen.hotpot.common.core.util.IdUtil;
import info.peigen.hotpot.component.data.repository.beetlsql.entity.AbstractCreateTimeEntity;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;

import static info.peigen.hotpot.common.core.enums.YesOrNo.N;
import static info.peigen.hotpot.common.core.enums.YesOrNo.Y;


/**
 * <b>(FeeRuleEntity)</b>
 * 收费规则表
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/1
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
@Table(name = "fee_rule", comment = "收费规则表", charset = MySqlCharsetConstant.UTF8MB4, engine = MySqlEngineConstant.InnoDB)
@org.beetl.sql.annotation.entity.Table(name = "fee_rule")
public class FeeRuleEntity extends AbstractCreateTimeEntity {
    @Column(name = "rule_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "ruleId")
    @Unique(value = "ruleId", columns = "rule_id")
    @org.beetl.sql.annotation.entity.Column("rule_id")
    @Builder.Default
    String         ruleId  = IdUtil.id();
    @Column(name = "name", type = MySqlTypeConstant.VARCHAR, length = 100, isNull = false, comment = "收费规则名称")
    @org.beetl.sql.annotation.entity.Column("name")
    String         name;
    @Column(name = "station_parent_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "收费针对的站点")
    @Index(value = "stationParentId", columns = "station_parent_id")
    @org.beetl.sql.annotation.entity.Column("station_parent_id")
    String         stationParentId;
    @Column(name = "account_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "收费针对的客户")
    @Index(value = "accountId", columns = "account_id")
    @Unique(value = "accountId", columns = "account_id,method,code,currency")
    @org.beetl.sql.annotation.entity.Column("account_id")
    String         accountId;
    @Column(name = "method", type = MySqlTypeConstant.VARCHAR, length = 50, isNull = false, comment = "收费方式")
    @Index(value = "method", columns = "method")
    @org.beetl.sql.annotation.entity.Column("method")
    FeeMethod      method;
    @Column(name = "code", type = MySqlTypeConstant.VARCHAR, length = 50, isNull = false, comment = "收费产品码")
    @Index(value = "code", columns = "code")
    @org.beetl.sql.annotation.entity.Column("code")
    FeeProductCode code;
    @Column(name = "type", type = MySqlTypeConstant.VARCHAR, length = 50, isNull = false, comment = "收费规则类型")
    @org.beetl.sql.annotation.entity.Column("type")
    FeeType        type;
    @Column(name = "currency", type = MySqlTypeConstant.VARCHAR, length = 3, comment = "币种")
    @org.beetl.sql.annotation.entity.Column("currency")
    Currency       currency;
    @Column(name = "billing", type = MySqlTypeConstant.VARCHAR, length = 1, isNull = false, defaultValue = "N", comment = "是否计费-默认不计费")
    @org.beetl.sql.annotation.entity.Column("billing")
    @Builder.Default
    String         billing = N.name();
    @Column(name = "charge", type = MySqlTypeConstant.VARCHAR, length = 1, isNull = false, defaultValue = "Y", comment = "是否收费-直接收费")
    @org.beetl.sql.annotation.entity.Column("charge")
    @Builder.Default
    String         charge  = Y.name();
    @Column(name = "context", type = MySqlTypeConstant.VARCHAR, length = 2000, isNull = false, comment = "收费规则具体内容")
    @org.beetl.sql.annotation.entity.Column("context")
    String         context;
    @Column(name = "billing_account_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "被计费客户Id")
    @org.beetl.sql.annotation.entity.Column("billing_account_id")
    String         billingAccountId;
    @Column(name = "payer_account_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "付费账户Id")
    @org.beetl.sql.annotation.entity.Column("payer_account_id")
    String         payerAccountId;
    @Column(name = "payee_account_id", type = MySqlTypeConstant.VARCHAR, length = 30, isNull = false, comment = "收费账户Id")
    @org.beetl.sql.annotation.entity.Column("payee_account_id")
    String         payeeAccountId;
    @Column(name = "memo", type = MySqlTypeConstant.VARCHAR, length = 200, comment = "备注")
    @org.beetl.sql.annotation.entity.Column("memo")
    String         memo;
}